﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="adminQuestion.aspx.cs" Inherits="Admin_adminQuestion"  Async="true"%>
<%@ Register Src="adminfoot.ascx" TagName="adminfoot" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link rel="stylesheet" href="imgs/admin.css" type="text/css" media="all" />
    <script type="text/javascript" src="../DotNet_net/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="imgs/GetAjax.js"></script>
    <script type="text/javascript" src="../DotNet_net/js/common.js"></script>
    <style type="text/css">
    .gongdan{
height:30px;
line-height:30px;
font-size:12px;
color:#000000;
font-weight:bold;
text-align:center;
background-color:#EDEEE7;
}
.gongdan1{
font-size:12px;
color:#000000;
text-align: center;
padding:6px;
background-color:#ffffff;
text-align:left;
}
.phuida{
background-color: #F2F2F2 ;
color:#666666;
text-align:left;
}
.phuida1{
background-color: #ffffff ;
color:#0033CC;
padding:3px 6px;
text-align:left;
}
.style2{
color:#0033CC;
font-weight:bold;
}
.faq_info {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:#FDFBEA none repeat scroll 0 0;
border:1px solid #E1D897;
line-height:16px;
margin-bottom:5px;
padding:4px;
color:#666666;
text-align:left;
}
    </style>
</head >
<body onload="$('#loading').hide()">
  <form id="form1" runat="server">   
<div class="cpcontainer" id="cpcontainer">
 <div id="loading" style="display:block">   
    <div class="loading-indicator">   
        页面正在加载中...   
    </div>   
</div> 
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="tb2"><%=input %>
<tr  class="thead"><td colspan="6" align="left" >问题管理(<font color='red'>＊</font>为必填,其它选填)</td></tr>
<tr>
<td>问题类别：</td>
<td align="left">
<select id="qClass"style="width:220px;" onchange="appendProductClassDp()">
        <%=QuestionClassDp()%>
</select>
</td>
<td> 产品类别：</td>
<td align="left">
<select onchange="appendProductId()" id="ProductClassDp">
   <option value="0">--没有与问题相关的产品类别--</option>
</select>
</td>
<td colspan="2" align="left">
<span id="ProductIdDp_span">相关产品：
<select id="ProductIdDp" >
<option  value="">--没有与问题相关的产品--</option>
</select>
    &nbsp;</span>
</td>
</tr>
<tr>
<td>
    提问的用户</td>
<td align="left">
    <select id="selectUser" style="width: 218px">
        <%=UserDp() %>
    </select></td>
<td>
    问题状态：</td>
<td align="left">
    &nbsp;<select id="selectState" style="width: 187px">
        <option value="0" selected="selected">问题开启</option>
        <option value="1">问题关闭</option>
    </select></td>
<td>
<input type="button" name="selectBtn"  value="查 询..." class="btn" onclick='SelectKey("?")'/></td>
<td></td>
</tr>
<tr>
<td width="12%" class="gongdan"  style="text-align:center">问题ID</td>
<td width="20%" class="gongdan"  style="text-align:center">标题</td>
<td width="10%" class="gongdan"  style="text-align:center">问题类别</td>
<td width="10%" class="gongdan"  style="text-align:center">状态</td>
<td width="16%" class="gongdan"  style="text-align:center">提交时间</td>   
<td width="11%" class="gongdan"  style="text-align:center">提问的用户</td>
<td width="21%" class="gongdan"  style="text-align:center">问题操作</td>
</tr>
</table>
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<div>
<table width="100%" border="0" cellspacing="1" cellpadding="0" >    
</HeaderTemplate>
<ItemTemplate >
   <tr>
    <td width="12%" class="gongdan1"  style="text-align:center">&nbsp;<input  type="checkbox" class="checkbox" value="<%#Eval("QuestionID") %>" name="m_id"><%#Eval("QuestionID") %></td>
    <td width="20%" class="gongdan1" style="text-align:center"><a title="<%#Eval("QuestionID") %>" onclick="toggleArea(this.title)" href="javascript:void(0)"><%#Eval("Title") %></a> &nbsp;&nbsp;
    <span id="span_<%#Eval("QuestionID") %>"><%#closeImg(Eval("QuestionState"),Eval("QuestionID"))%></span> 
    </td>       
    <td width="10%" class="gongdan1" style="text-align:center"><%#getQuestionClassName(Eval("QuestionClassID"))%></td>
    <td width="10%" class="gongdan1" style="text-align:center" id="state<%#Eval("QuestionID") %>"><%#Eval("QuestionState").ToString() == "False" ? "<span style=\"color:Red\">处理中</span>" : "已关闭"%> <span style="color:Green"><%#getCount(Eval("QuestionID"), Eval("QuestionState"))%></span></td>
    <td width="16%" class="gongdan1" style="text-align:center"> <%#Eval("PostTime", "{0:G}")%> </td>
    <td width="11%" class="gongdan1" style="text-align:center"><span id="userName_span<%#Eval("QuestionID") %>" title="<%#Eval("IsSend") %>"><%#Eval("UserName") %></span></td>
    <td width="21%" class="gongdan1" style="text-align:center"><input id="Button1" title="<%#Eval("QuestionID") %>" onclick="del(this.title)" class="btn" type="button" value="删除问题" /></td>
  </tr>  
<!--start-->
<tr id='<%#Eval("QuestionID") %>' style="display:none" title="0">
<td colspan="6" style="padding:6px; background:#FFFFFF;">
<div>
<div id="QuestionContent<%#Eval("QuestionID") %>" style="text-align:left">
读取中...
</div>
</div>
</td>
</tr>
<!--end-->
</ItemTemplate>
<FooterTemplate>  
</table>
</div>
<table width="100%" border="0" cellspacing="1" cellpadding="0" bgcolor="#a6a79d">
<tr>
<td colspan="5" style="text-align:left; padding:6px; background-color:#fff;"><span style="float:left"><div class="pages">
<%QuestionPagingHtml();%></div></span></td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>  
 <table class="tb" id="tbS" style="text-align:left"><tr><td>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'m_id')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onclick="checkOthers('m_id')" />
     &nbsp;&nbsp;&nbsp;移动到
   
    <select id="qcDp" style="width:150px">
           <% =QuestionClassDp()%>
    </select>
       <input class="btn" name="button" onclick="doPostMove('','m_id');" type="button" value="批量移动分类" /></td></tr></table>
 <uc1:adminfoot ID="Adminfoot1" runat="server" />
    </div>
</form>
<script type="text/javascript" language="javascript">
    function SubmitQuestion(qid,contentId)
    {
        $("#loading").show();
        var userName=$("#userName_span"+contentId).text();  
        var IsSend= $("#userName_span"+contentId).attr("title");     
        var url="";
        var param="";
        url=convertURL("adminQuestion.aspx?action=answer&qid="+qid+"&contentId="+contentId);
        param="&txt="+$("#txt"+qid).attr("value")+"&userName="+userName+"&isSend="+IsSend;        
        ajax_post(url,param,function(msg)
        {   
            if(msg=="1")
            {
                $("#loading").hide();
                alert("回答内容不能为空，请填写完整！");
            }
            else
            {
                $("#QuestionContent"+contentId).empty().append(msg);   
                $("#loading").hide();  
            }    
       });
    }
    function toggleArea(qid)
    {
        $("#"+qid).toggle();       
        if($("#"+qid).attr("title")=="0")
        {
             var url=convertURL("adminQuestion.aspx?action=show&qid="+qid);                 
             ajax_get(url,'',function(msg)
             {  
                    $("#QuestionContent"+qid).empty().append(msg);
                    $("#"+qid).attr("title","1");
             });
        }        
    }  
    function changePage(name)
    {
//        var pid=convertURL($(name).attr("name"));
//        $.get(pid,'',function(data,state){$("#cpcontainer").empty().append(data)}); 
    }
    function del(qid)
    {
       
        if(confirm('确定要删除吗？'))
        {  $("#loading").show();
             var url="";       
            url=convertURL("adminQuestion.aspx?action=del&qid="+qid+$("#HiddenUrl").attr("value"));
            ajax_post(url,'',function(msg)
            {  
                 $("#cpcontainer").empty().append(msg); 
                 $("#loading").hide();  
            });
        }
    } 
    function appendProductClassDp()
    {
             var url=""; 
             var questionState=escape($("#qClass :selected").attr("title"));             
             if(questionState=="True")
             {
                 url=convertURL("adminQuestion.aspx?action=appendProductClassDp");
                 ajax_get(url,'',function(msg)
                 {   
                     $("#ProductClassDp").html(msg);
                     appendProductId();            
                });
            }  
            else
            {
                $("#ProductClassDp").html("<option value=\"-1\">--没有与问题相关的产品类别--</option>");
                $("#ProductIdDp").html("<option value=\"\">--没有与问题相关的产品--</option>");  
            }
    }
    function appendProductId()
    {
             var selectValue=$("#ProductClassDp :selected").attr("value");            
             if(selectValue!="0")
             {
                 var url=""; 
                 url=convertURL("adminQuestion.aspx?action=appendProductId&productId="+escape($("#ProductClassDp :selected").attr("value")));
                 ajax_get(url,'',function(msg)
                 {   
                    if(msg=="1")
                    {   
                          $("#ProductIdDp").html("<option value=\"\">--没有与问题相关的产品--</option>");
                    }
                    else
                    {
                        $("#ProductIdDp").html(msg);  
                    }
                });
            }
            else
            {
                 $("#ProductIdDp").html("<option value=\"\">--请选择产品类别--</option>");
            }
    }  
        
    function SelectKey(url)
    {
            $("#loading").show();
           url=convertURL("adminQuestion.aspx?user="+escape($("#selectUser :selected").attr("value"))+"&qcid="+escape($("#qClass option:selected").attr("value"))+"&CurrentIndex=1&pid="+escape($("#ProductIdDp option:selected").attr("value"))+"&state="+escape($("#selectState option:selected").attr("value")));
           $("#loading").show();
          ajax_get(url,'',function(msg)
          {
             $("#cpcontainer").empty().append(msg);
             $("#loading").hide();
          });
       
    }
    function closeQuestion(qid)
    {
        var url=convertURL("adminQuestion.aspx?action=close&qid="+qid); 
        if(confirm('确定要关闭吗？'))
        {             
             $("#loading").show();            
             ajax_get(url,'',function(msg)
             { 
                 if(msg=="1")
                 {  
                      $("#span_"+qid).html("") 
                      $("#state"+qid).html("已关闭");  
                      $("#QuestionContent"+qid).empty().append("读取中..."); 
                      $("#"+qid).attr("title","0");     
                      $("#"+qid).hide() 
                      $("#loading").hide();   
                }        
             });
        }
    }
    function deleteQuestion(fid,qid)
    {
        var url=convertURL("adminQuestion.aspx?action=delete&qid="+qid+"&fid="+fid); 
        if(confirm('确定要删除吗？'))
        {            
            $("#loading").show();             
             ajax_get(url,'',function(msg)
             { 
                 $("#QuestionContent"+fid).empty().append(msg);
                 $("#loading").hide();
             });
        }
    }
    
 function doPostMove(url,sname)
 {
    var ids=getIDList(sname);              
    if(ids!="")
    {
        var yidong="";
        var Param="";           
        yidong=document.getElementById("qcDp").options[document.getElementById("qcDp").selectedIndex].value;
        if((confirm("确定要移动这些记录?"))==true)
        {
            $("#loading").hide();
            url=convertURL(url+"adminQuestion.aspx?action=MoveAll&id="+yidong+"&qids="+ids);             
            ajax_get(url,'',function(msg)
            {                   
               $("#cpcontainer").empty().append(msg);    
               $("#loading").hide();                
            });
        }
    }
    else
    {
        alert("您还没有选择移动项");
        return false;
    }
}      
</script>
</body>
</html>
